package com.csd.action.export;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import com.csd.helper.ActionResult;
import com.csd.helper.Tool;
import com.csd.pojo.Project;
import com.csd.service.IProjectService;
import com.csd.serviceImpl.ProjectService;

import com.rpms.util.ExcelExport;

public class ExportProjectAction {
	
	private String path ;
    
	private String stage;
	
	private ProjectService projectService;
	
	public String getPath() 
	{
		return path;
	}

	public void setPath(String path) 
	{
		this.path = path;
	}

	public ProjectService getProjectService() 
	{
		return projectService;
	}

	public void setProjectService(ProjectService projectService) {
		this.projectService = projectService;
	}

	
	
	public String getStage() {
		return stage;
	}

	public void setStage(String stage) {
		this.stage = stage;
	}
	

	public String execute(){
		String result = ActionResult.fail;
		ExcelExport excelExport = new ExcelExport();
		List<String> names = new ArrayList<String>();
		names.add("ID");
		names.add("老师");
		names.add("研究领域");
		names.add("开发团队");
		names.add("项目类型");
		names.add("工程编号");
		names.add("工程名称");
		names.add("*项目申请时间");
		names.add("项目结束时间");
		names.add("项目介绍");
		names.add("项目开发所处状态");
		names.add("项目最后得分");
		names.add("**项目等级");
		names.add("开发周期");
		
		List<Project> items = null;
		String fileName = "";
		if(stage.equals("1"))
		{
		   items = projectService.listApplyProject();
		   fileName = "申请评审项目.xls";
		}else if(stage.equals("2")){
			 items = projectService.listEvaluateProject();
			 fileName = "评审中的项目.xls";
		}else if(stage.equals("3")){
			 items = projectService.listFinshProject();
			 fileName = "结题的项目.xls";
		}else {
			return result;
		}
		
		
		 try {
			excelExport.write(fileName, names, items);
			path  = "userfile"+File.separator+"excel"+File.separator+fileName;
			System.out.println("path:_____"+path);
		} catch (Exception e) {
			e.printStackTrace();
			return result;
		}
		
		result = ActionResult.success;
		return result;
	}

	

	
	

}
